module ProjectsHelper
  def trans_current_state_to_chs(string)
    case string
    when "need_to_release"
      "未量产"
    when "released"
      "已量产"
    when "freeze"
      "冻结"
    end
  end

  def get_project_state_op(string)
    case string
    when "need_to_release"
      "量产"
    when "released"
      "冻结"
    when "freeze"
      "重新打开"
    end
  end

  def sort_td_class_helper(param)
    result = 'class="sortup"' if params[:sort] == param
    result = 'class="sortdown"' if params[:sort] == param + "_reverse"
    return result
  end

  def sort_link_helper(text, param)
    key = param
    key += "_reverse" if params[:sort] == param
    options = {
      :url => {:action => 'show', :params => params.merge({:sort => key, :page => nil})},
      :update => 'table',
      :before => "Element.show('spinner')",
      :success => "Element.hide('spinner')"
    }
    html_options = {
      :title => "Sort by this field",
      :href => url_for(:action => 'show', :params => params.merge({:sort => key, :page => nil}))
    }
    link_to_remote(text, options, html_options)
  end

end
